
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace jzlib.asp.net.Controls
{
    public class NumberColumnItemTemplate:ITemplate
    {
        private GridView gridView;
        public  NumberColumnItemTemplate(GridView gv)
        {
            this.gridView = gv;
        }
        public void InstantiateIn(Control container)
        {
            Literal l = new Literal();         
            l.DataBinding += new EventHandler(l_DataBinding);
            container.Controls.Add(l);
        }

        void l_DataBinding(object sender, EventArgs e)
        {
            Literal l = sender as Literal;
            if (l != null)
            {
                GridViewRow row = (GridViewRow)l.NamingContainer;
                l.Text = (row.DataItemIndex + 1).ToString();
            }
        }
    }
}
